<template>
	<view>
		<cu-custom :key="'header'+headerKey" bgColor="bg-blue-light" :isBack="true" backText="返回"
		title="人才生活补贴查询"></cu-custom>
		<view class="bg-blue-light" style="height: 150rpx;border-radius: 0 0 50rpx 50rpx;">
		</view>
		<view class="card" style="height: 400rpx;margin-top: -150rpx;">
			<view class="head">
				请填写个人信息
			</view>
			<zh-input v-model="aac003" type="text" label="姓名"
			labelAlign="left" inputAlign="right" :required="true" 
			placeholder="请输入姓名" ></zh-input>
			<zh-input v-model="aac002" type="text" label="身份证号码"
			labelAlign="left" inputAlign="right" :required="true" 
			 placeholder="请输入身份证号"></zh-input>
				<view class="button"
				style="padding-top: 10rpx;margin-left: 100rpx; width: 300rpx;">
					<button class="cu-btn shadow margin-tb-sm lg bg-blue-light"
					 style="background-color: #1388ED; width: 500rpx;" @tap="up">确定</button>
				</view>
		</view>	
		<view class="card" style="height: 360rpx;margin-top: 300rpx;">
			<view class="head">
				引进人才生活补贴数据信息
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 姓名：                                    {{aac003}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 身份证：                     {{aac002}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 学历：                                 {{th0701}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 毕业院校：                       {{th0702}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 单位名称：   {{aab005}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 专业：                             {{th1201}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 毕业时间：                              {{th1202}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 首次参保年月：                            {{aac049}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 补贴金额：                                 {{th1203}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 企业纳税地：                              {{th1205}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 企业注册地：                              {{th1206}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 企业性质：                              {{th1207}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 第一年补贴金额：                           {{th1301}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 第二年补贴金额：                           {{th1302}}</text>
				</view>
			</view>
			<view class="cu-form-group ">
				<view class="text-content" >
				       <text space="ensp"> 第三年补贴金额：                           {{th1303}}</text>
				</view>
			</view>
		</view>
		<view class="card" style="height: 360rpx;margin-top: 1770rpx;">
			<view class="head">
				请填写个人相关信息
			</view>
			<zh-input v-model="th1204" type="text" label="手机号码"
			labelAlign="left" inputAlign="right" :required="true" 
			placeholder="请输入手机号码"></zh-input>
			<zh-input v-model="aae010" type="text" label="银行账号"
			labelAlign="left" inputAlign="right" :required="true" 
			placeholder="请输入银行账号"></zh-input>
			<zh-input v-model="aae008" type="text" label="开户银行"
			labelAlign="left" inputAlign="right" :required="true" 
			placeholder="请输入开户银行"></zh-input>
			<zh-input v-model="aae013" type="text" label="备注"
			labelAlign="left" inputAlign="right" :required="false" 
			
			placeholder="请输入备注"></zh-input>
			<zh-input v-model="th1304" type="text" label="已领取金额"
			labelAlign="left" inputAlign="right" :required="true" 
			placeholder="请输入已领取金额"></zh-input>
			<zh-text  :required="true" type="text" label="合同照片" labelAlign="left" inputAlign="right" :rightButtonFlag="true" :rightButton="{text:'上传照片',bg:'bg-white',color:'#0000C6',textFlag:true}" @right-button-click="ChooseImage('avatar')" ></zh-text>
			<zh-text  type="text" label="优秀校级毕业生照片" labelAlign="left" inputAlign="right" :rightButtonFlag="true" :rightButton="{text:'上传照片',bg:'bg-white',color:'#0000C6',textFlag:true}" @right-button-click="ChooseImage('photo')" ></zh-text>
			<view class="button"
			style="padding-top: 10rpx;margin-left: 100rpx; width: z300rpx;">
				<button class="cu-btn shadow margin-tb-sm lg bg-blue-light"
				 style="background-color: #1388ED; width: 500rpx;" @tap="save">保存</button>
			</view>
			
		</view>
	</view>
</template>

<script>
	import store from '@/store';
	import commonApi from '@/api/system/common.js'
	import api from '@/api/society/home/livingallowance.js';
	import reqConfig from '@/common/config/reqConfig.js';
	export default {
		onShow() {
			this.headerKey += 1;
		},
		data() {
			return {
				headerKey:0,
				userId:store.state.hh_user.userId,
				fullName:store.state.hh_user.fullName,
				userType:store.state.hh_userType,
                 aac003:'',
				 aac002:'',
				 th0701:' ',
				 th0702:' ',
				 aab005:' ',
				 th1201:' ',
				 th1202:' ',
				 aac049:' ',
				 th1203:' ',
				 th1205:' ',
				 th1206:' ',
				 th1207:' ',
				 th1208:'0',
				 th1301:' ',
				 th1302:' ',
				 th1303:' ',
				 th1204:' ',
				 aae010:' ',
				 aae008:' ',
				 aae013:' ',
				 th1304:' ',
				 htpicture:' ', 
				 xjpicture:' ', 
				photoPath: '',
				 photo: '',
				 formData: {},
			}
		},
		methods: {
			up: function() {
				const data = {};
				data.aac003 = this.aac003
				data.aac002 = this.aac002
				console.log(data.aac003)
				console.log(data.aac002)
				this.$http
					.post(api.query,data)
					.then(res => {
						this.show = true;
						this.aac003 = res.result.aac003;
						this.aac002 = res.result.aac002;
						this.th0701 = res.result.th0701;
						this.th0702 = res.result.th0702;
						this.aab005 = res.result.aab005;
						this.th1201 = res.result.th1201;
						this.th1202 = res.result.th1202;
						this.aac049 = res.result.aac049;
						this.th1203 = res.result.th1203;
						this.th1205 = res.result.th1205;
						this.th1206 = res.result.th1206;
						this.th1207 = res.result.th1207;
						this.th1301 = res.result.th1301;
						this.th1302 = res.result.th1302;
						this.th1303 = res.result.th1303;
					})
					.catch(err => {});
			},
			save:function()
			{
				const data = {};
				 const that = this
				data.aac003 = this.aac003;
				data.aac002 = this.aac002;
				data.th0701 = this.th0701;
				data.th0702 = this.th0702;
				data.aab005 = this.aab005;
				data.th1301 = this.th1301;
				data.th1302 = this.th1302;
				data.aac049 = this.aac049;
				data.th1303 = this.th1303;
				data.th1205 = this.th1205;
				data.th1206 = this.th1206;
				data.th1207 = this.th1207;
				data.th1201 = this.th1201;
				data.th1202 = this.th1202;
				data.th1203 = this.th1203;
				data.th1204 = this.th1204;
				data.aae010 = this.aae010;   
				data.aae008 = this.aae008;
				data.aae013 = this.aae013;
				data.th1208 = this.th1208;
				data.htpicture = this.htpicture;
				data.xjpicture = this.xjpicture;
				this.$http
					.post(api.save,data)
					.then(res => {
						uni.showModal({
						    title: '提示',
						    content: '提交成功',
						    success: function (res) {
						       
						    }
						});
					}).catch(error => {
						
					});
			},
			ChooseImage(type) {
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						new Promise((resolve, reject) => {
						    uni.uploadFile({
						        url: reqConfig.jhrsUrl+commonApi.uploadFile, //仅为示例，非真实的接口地址
						        filePath: res.tempFilePaths[0],
						        name: 'file',
						        formData: {
						            'uploaderId': this.userId,
									'uploader':this.fullName,
									'fileClassCode':'20'
						        },
						        success: function (uploadFileRes) {
						    		const fileRes = JSON.parse(uploadFileRes.data)
									resolve(fileRes);
						    		
						    		
						        },
						    	fail:function(error){
									reject(error);
						    		
						    	}
						    })
						}).then(data => {
								console.log(data);
								if(!data){
									uni.showToast({
										icon: 'none',
										title: "上传文件失败",
										duration:2000
									})
									return
								}
								if(data &&data.code!== 0){
									uni.showToast({
										icon: 'none',
										title: data.message,
										duration:2000
									})
									return
								}
								const file = data.result.file
								if(!file.flag){
									uni.showToast({
										icon: 'none',
										title: "上传文件失败",
										duration:2000
									})
									return
								}
								const showId = file.showId
								let url = reqConfig.jhrsUrl+commonApi.showFile+"/"+showId
								console.log(type)
								if(type=='photo'){
									this.photo=url
									this.formData.photo=url
									if(this.photoShowId){
										if(showId!=this.photoShowId){
											this.DelImg(this.photoShowId)
										}
									}
									this.xjpicture = showId
									this.formData.photoShowId = showId
								}else{
									this.photoPath=url
									this.formData.photoPath=url
									if(this.avatarShowId){
										if(showId!=this.avatarShowId){
											this.DelImg(this.avatarShowId)
										}
									}
									this.htpicture = showId
								}
					
								
							}).catch(err => {
								uni.showToast({
									icon: 'none',
									title: '上传文件失败：'+err.message,
									duration:2000
								})
							})
					}
				});
				console.log(this.htpicture)
			},
			DelImg(showId) {
				const data = {};
				data.uploaderId=this.userId
				data.uploader=this.fullName
				this.$jhrsHttp.post(commonApi.delFile+"/"+showId, data).then(res => {
				}).catch(error => {
					
				})
			},
					
		},

			}	
		
		
	
</script>

<style>
	page{
		background-color: #F6F6F6;
	}
	.card{
		background: #FFFFFF;
		border-radius: 20rpx;
		width: 690rpx;
		position: absolute;
		margin-left: 30rpx;
	}
	.button{
		position: absolute;
		margin-top: 1rpx;
		width: 1320rpx;
	}
	.head{
		height: 87rpx;
		width: 690rpx;
		line-height: 87rpx;
		font-family: 'PingFangTC-Medium';
		font-size: 30rpx;
		font-weight: bold;
		color: #333333;
		letter-spacing: 0;
		padding-left: 30rpx;
		border-bottom: 1px solid #DFDFDF;
	}
</style>
</style>
